package net.tngou.crawler.quartz;

import java.util.Date;
import java.util.List;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.tngou.crawler.drug.Tesseract_OCR;
import net.tngou.crawler.enums.StateEnum;
import net.tngou.crawler.jdbc.DBManager;
import net.tngou.crawler.jdbc.OrderType;
import net.tngou.crawler.pojo.Crawlerurl;
import net.tngou.crawler.pojo.Drug;
import net.tngou.crawler.pojo.POJO;
import net.tngou.crawler.pojo.Web;
import net.tngou.crawler.service.BaseService;
import net.tngou.crawler.service.CrawlerService;
import net.tngou.crawler.service.DrugService;


public class BarcodeJob implements Job {
	private static Logger _log = LoggerFactory.getLogger(BarcodeJob.class);
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		if(context!=null)
		_log.info("执行作业： "+context.getJobDetail().getKey() +"  执行时间："+new Date()+"********************************");
		
		BaseService service = new BaseService();
		String filter="barcode=''";
		List<Drug> list = (List<Drug>) service.getList(1, 100, filter, Drug.class);
		Tesseract_OCR ocr = new Tesseract_OCR();
		list.forEach(e->{
			ocr.updateBarcode(e);
		});
		
		DBManager.closeConnection();
	

	}
	
	public static void main(String[] args) throws JobExecutionException {
		while (true) {
			new BarcodeJob().execute(null);
			
		}
	
	}
	
}

